package com.example.vue_serve.controller;

import com.example.vue_serve.entity.TbUser;
import com.example.vue_serve.service.TbUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("user")
public class TbUserController {
    @Autowired
    private TbUserService tbUserService;

    @RequestMapping(value = "/findAll", method = RequestMethod.GET)
    public List<TbUser> findAll() {
        return tbUserService.findAll();
    }

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public String add(@RequestBody TbUser user) {

        return tbUserService.add(user);
    }

    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public String updateUser(@RequestBody TbUser user) {
        return tbUserService.updateUser(user);
    }

    @RequestMapping(value = "/del", method = RequestMethod.GET)
    public String delUser(@RequestParam int id) {
        return tbUserService.delUser(id);
    }

    @RequestMapping(value = "/queryByName", method = RequestMethod.POST)
    public List<TbUser> quertByName(@RequestBody TbUser user) {
        return tbUserService.queryBuName(user);
    }
    @RequestMapping(value = "/queryLikeName", method = RequestMethod.POST)
    public List<TbUser> queryLikeName(@RequestBody TbUser user) {
        return tbUserService.queryLikeName(user);
    }
    @RequestMapping(value = "/queryByTiaojian", method = RequestMethod.POST)
    public List<TbUser> queryByTiaojian(@RequestBody TbUser user) {
        return tbUserService.queryByTiaojian(user);
    }
}
